<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>展示</title>
    <%--需要引入各种css、js、jquery的插件--%>
    <script type="text/javascript" src="easyui1.7/jquery.min.js"></script>
    <script type="text/javascript" src="easyui1.7/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui1.7/locale/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" type="text/css" href="easyui1.7/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui1.7/themes/icon.css"/>
</head>
<body>
<div id="dg">
    <button><a href="add.jsp">添加</a></button>
    游戏名称: <input type="text" id="name"> <button onclick="searchGame()">搜索</button>
</div>
<table id="tg"></table>
</body>
<script>
    $(function () {
        show()
    })
    function searchGame() {
        show()
    }
    function show() {
        $('#tg').datagrid({
            url:'searchGame',
            fitColumns:true,
            columns:[[
                {field:'id',title:"id"},
                {field:'name',title:"游戏名称"},
                {field:'money',title:"是否氪金"},
                {field:'cmp',title:"研发公司"},
                {field:'img',title:"游戏logo",formatter:function (value,row,index) {
                        return "<img src='/img/"+row.img+"' width='30' height='30'/>"
                    }},
                {field:'cz',title:"操作",formatter:function (value,row,index) {
                    return "<a href=toUpdate?id="+row.id+">修改</a>"+" "+"<button onclick='godelete()'>删除</button>"
                    }},
            ]],
            pagination:true,
            pageNumber:1,
            pageSize:2,
            pageList:[2,3,4],
            toolbar:'#dg',
            queryParams:{
                name:$('#name').val()
            }
        })
    }
    function godelete() {
        var id = $('#tg').datagrid('getSelections')
        if (confirm("确认删除吗")){
            location.href="${pageContext.request.contextPath}/deleteById?id="+id[0].id
        }
    }
</script>
</html>
